package com.ticket.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ticket.entity.Team;
import com.ticket.mapper.TeamMapper;
import com.ticket.service.ITeamService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

@Service
public class TeamServiceImpl extends ServiceImpl<TeamMapper, Team> implements ITeamService {

    @Override
    public Page<Team> searchTeams(String keyword, int page, int size) {
        LambdaQueryWrapper<Team> queryWrapper = new LambdaQueryWrapper<>();
        
        if (StringUtils.hasText(keyword)) {
            queryWrapper.like(Team::getName, keyword)
                    .or()
                    .like(Team::getDescription, keyword);
        }
        
        return this.page(new Page<>(page, size), queryWrapper);
    }
} 